/*
 * Golazo GeoNotes
 * Copyright (C) 2009 Nakajiman Software Inc.
 * http://nakajiman.lrlab.to/
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License 
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * serverload
 */
function serverload() {

  // GET
  Golazo.dispatch(function(request, response, me) {

    var caller = request.data.caller || '';
    if (caller.substr(0, 1) != '/' &&
	  caller.indexOf(request.parsedUrl.base) != 0)
	    caller = '/home.html';

    var gadget = Golazo.Gadget.findByUrl(request.data.url || '')
	  || { id: 1, title: 'Full profile' };

    if (me && me.id && gadget.id == 1/*Members*/)
	    me.updateAttribute('expired', new Date());

	if (me && me.id)
	  $(document).me(me);

    $('title').text(
	  [ document.title, gadget.title ].join(' - ')
	);

    $('<span/>').text(gadget.title).appendTo('#breadcrumbs');

    $('#modulesFooter a').attr('href', caller);

  // POST
  }, function(request, response, me) {
    throw 'Method Not Allowed';
  });

};

/**
 * load
 */
function load() {
  
  google.friendconnect.container.renderUrlCanvasGadget({
    site: Golazo.GOOGLE_FCID, id: 'canvas'
  }, Golazo.GOOGLE_FCSKIN);

};
load.runat = 'client';